class Solution(object):
    def addNegabinary(self, arr1, arr2):
        if len(arr1) < len(arr2):
            arr1, arr2 = arr2, arr1
        arr1.reverse()
        arr2.reverse()
        n1 = len(arr1)
        n2 = len(arr2)
        add = 0
        index = 0
        while index < n1 and index < n2:
            now_val = arr1[index] + arr2[index] + add
            add = - (now_val // 2)
            arr1[index] = now_val % 2
            index += 1
        while index < n1:
            now_val = arr1[index] + add
            add = - (now_val // 2)
            arr1[index] = now_val % 2
            index += 1
        if add == -1:
            arr1 += [1, 1]
        if add == 1:
            arr1 += [1]
        arr1.reverse()
        n = len(arr1)
        index = 0
        while index < n:
            if arr1[index] == 1:
                break
            else:
                index += 1
        if index == n:
            return [0]
        else:
            return arr1[index:]



